
class Solution:
    # @param {string} s
    # @return {integer}
    def lengthOfLongestSubstring(self, s):
        last = [ -1 ] * 256
        ans = 0
        cur = 0

        for index, value in enumerate(s):
            cur = min(cur+1, index-last[ord(value)])
            ans = max(ans, cur)
            last[ord(value)] = index
        
        return ans

